package com.xc.controller;


import com.xc.dto.ResultDTO;
import com.xc.entity.LoginEntity;
import com.xc.entity.UserEntity;
import com.xc.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Api(tags = "用户登录")
public class LoginController {
    @Autowired
    private UserService userService;
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @PostMapping("/login")
    @ApiOperation("返回200成功，同时msg返回jwt，-1失败")
    public ResultDTO login(@RequestBody LoginEntity loginEntity) {
//        userEntity.setVCode(redisTemplate.opsForValue().get(userEntity.getUuid()));
//        redisTemplate.delete(userEntity.getUuid());
        return userService.login(loginEntity);
    }
}
